package utils

const (
	E_FAIL = 0
	S_OK   = 1

	E_UNKNOWN       = 1000
	E_INVALID_PARAM = 1001
	E_NOT_FOUND     = 1002
	E_OP            = 1003
	E_TOKEN         = 1004
	E_TIMEOUT       = 1005
)

const (
	MSG_UNKNOW        = "unknown"
	MSG_INVALID_PARAM = "invalid param"
	MSG_NOT_FOUND     = "not found"
	MSG_TIMEOUT       = "timeout"
)

type ResultResp struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func NewResp(code int, msg string, data interface{}) *ResultResp {
	resp := &ResultResp{
		Code:    code,
		Message: msg,
		Data:    data,
	}
	return resp
}

func NewOkResp(data interface{}) *ResultResp {
	return NewResp(S_OK, "OK", data)
}

func NewFailResp(code int, msg string) *ResultResp {
	return NewResp(code, msg, nil)
}
